<%-- 
    Document   : Product Maintenance
    Created on : 2014/2/24, 下午 02:05:56
    Author     : Gjun
--%>

<%@page import="Filter.DAO"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<style type="text/css">
    #Table1 {border-width:1px ; border-style: solid;}
    #Table1 thead { background-color:#854806; color: white; font-weight:bold; }
    #Table1 td{ padding:10px; text-align:center;}
   
</style>
<%
    String num ="0";
    
    String sql="SELECT * from product";
    DAO dao =new DAO(); 
    if (request.getParameter("num")!=null && request.getParameter("num")!="")
        num = Integer.toString(Integer.parseInt(request.getParameter("num"))*5);      
    //取資料
    ArrayList<HashMap> rslist= dao.query2(sql, new String[]{}, num , "1000");
    int fin=dao.GGININ()/Integer.parseInt("1000");
    if(dao.GGININ()%Integer.parseInt("1000")==0)
        fin--;
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <table id="Table1" border="1">
            <thead>
                <tr>
                    <th>產品編號</th>
                    <th>產品名稱</th>
                    <th>產品縮圖</th>              
                    <th>產品價格</th>
                    <th>產品介紹</th>
                    <th>庫存量</th>
                    <th>功能</th>
                </tr>
            </thead>
            <tbody>
            <%
                for(int i =0;i<rslist.size();i++)
                {
                    HashMap map =rslist.get(i);
                    out.println("<tr><td>"+map.get("product_id")+
                            "</td><td>"+map.get("product_name")+
                            "</td><td><a href='"+map.get("img_url")+
                            "' target='_blank'><img style='width:100px;height:80px;'src='"+
                            map.get("img_url")+"'/></a>"+
                            "</td><td>"+map.get("product_price")+
                            "</td><td>"+map.get("product_info")+
                            "</td><td>"+map.get("product_stock")+
                            "</td><td>"+"<a href='ProductUpdate.jsp?product_id="+map.get("product_id")+"'>修改</a><br>"
                            + "<a href='ProductDelete.jsp?product_id="+map.get("product_id")+"'>刪除</a></td></tr>");
                }
            %> 
            </tbody>

        </table> 
            <div style="position: fixed; top: 5%; right: 5%;">     
                <form action="s1.jsp">
                    <p style="font-size:20px;">查詢TOP<INPUT type="text" name="number"><input type="submit" value="查詢" style="width: 40px; height:30px"/></p>
                </form>
            </div>
            
            <div style="position: fixed; top: 15%; right: 5%;">     
                <form action="s2.jsp">
                    <p style="font-size:20px;">月份銷售金額<input type="submit" value="查詢" style="width: 40px; height:30px"/></p>
                </form>
            </div>

            <div style="position: fixed; top: 5px; right: 35%;">     
                <form action="OrderList.jsp">
                    <p style="font-size:20px;"><input type="submit" value="訂單統計" style="width: 65px; height:40px"/></p>
                </form>
            </div>
            <div style="position: fixed; top: 50px; right: 35%;">         
                <form action="ProductInsert.jsp">
                    <p style="font-size:20px;"><input type="submit" value="新增" style="width: 65px; height:40px"/></p>
                </form>
            </div>
    </body>
</html>
